﻿using SketchUpAPI.NET.Geometry;
using SketchUpAPI.NET.Objects;
using SketchUpAPI.NET.SketchUp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SketchUpConsole.Examples
{
    /// <summary>
    /// 创建圆柱体
    /// </summary>
    public static class CreateGeometry
    {
        public static void Run()
        {
            string writePath = @"ExampleFiles\1.skp";

            SketchUpApplication.Initialize();

            SketchUpModel skp = SketchUpModel.Create();

            // 直接添加到模型中
            Sphere sp = new Sphere(Point3D.Origin, 100.ToModel());
            skp.Entities.Add(sp.ToGeometry(), true);

            // 添加到群组中示例
            Cylinder cy = new Cylinder(new Point3D(200.ToModel(), 0, 0), 100.ToModel(), 100.ToModel());
            cy.Normal = new Vector3D(1, 1, 1);
            skp.Entities.Add(cy.ToGeometry(), true, true);

            // 添加一个四边面球
            SphereQuads sq = new SphereQuads(new Point3D(400.ToModel(), 0, 0), 100.ToModel());
            skp.Entities.Add(sq.ToGeometry(), true, true);

            skp.Save(writePath, SketchUpAPI.NET.Enums.SUModelVersion.SU2020);
            skp.Dispose();
            SketchUpApplication.Terminate();
        }
    }
}